<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.veryedu.hibernate.hbm.entity.Film" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>选择座位</title>
    <link rel="stylesheet" href="../css/icomoon.css" />
	<link rel="stylesheet" href="../css/bootstrap.css" />
	<link rel="stylesheet" href="../css/index.css" />
	<script type="text/javascript" src="../js/jquery-1.10.2.js"></script>
	<script type="text/javascript" src="../js/bootstrap.js"></script>
	<script type="text/javascript" src="../js/icomoon.js"></script>
	<script>
	$(document).ready(function () {
		$(".bs-glyphicons li").click(function(){
			var cls = $(this).attr("class");
			if(cls == "sold"){
				alert("该座位已经售出！");
			}else if(cls == "selected"){
				$(this).removeClass("selected");
				$(this).find("[name='buySeats']").attr("checked",false);
			}else{
				$(this).addClass("selected");
				var seatId = $(this).attr("value");
				$(this).find("[name='buySeats']").attr("value",seatId);
				$(this).find("[name='buySeats']").attr("checked",true);
			}
		});
		
		$("#seatForm").submit(function(){
			var type = $("input:radio:checked").attr("id");
			var remainNum = $(".bs-glyphicons li:not(.sold)").length;
			if(type=="teamPrice"){
				var seatNum = $("input:checkbox:checked").length;
				if(remainNum < 6){
					if(seatNum < remainNum){
						alert("订购团体票，至少要一次性订购6张！当剩余座位不够6个时，需订购全部剩余座位。");
						return false;
					}
				}else{
					if(seatNum < 6){
						alert("订购团体票，至少要一次性订购6张！请重新选择");
						return false;
					}
				}
			}
		});
	});
	</script>
  </head>
  
  <body>
  	   
    <div class="container"> 
    <div class="navbar navbar-inverse navbar-default" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#"><h1>VeryEdu 影院订票系统</h1></a>
        </div>
        <div class="navbar-collapse collapse">
          
        </div><!--/.navbar-collapse -->
      </div>
    </div>
    </div>


<div class="container">			
			<div class="row row-offcanvas row-offcanvas-left">
            	<div class="col-xs-6 col-sm-3 sidebar-offcanvas">
                            
                    <ul class="nav nav-pills nav-stacked">
                      <li><a href="#"><span class="icon-camera"></span><span class="mls"> 浏览影片</span></a></li>
                      <li><a href="#"><span class="icon-bell"></span><span class="mls"> 浏览场次</span></a></li>
                      <li class="active"><a href="#"><span class="icon-users"></span><span class="mls"> 选择座位</span></a></li>                  
                      <li><a href="#"><span class="icon-coin"></span><span class="mls"> 支付订单</span></a></li>                
                      <li><a href="#"><span class="icon-numbered-list"></span><span class="mls"> 查看订单</span></a></li>
                    </ul>
                
                </div>
            	<div class="col-xs-12 col-sm-9">
                	<div class="row">
                		<div class="col-xs-1 col-sm-1"></div>
                    	<div class="col-xs-10 col-sm-10 text-center" style="background-color:#428bca; color:#FFF"><h4>屏幕</h4></div>
                		<div class="col-xs-1 col-sm-1"></div>
                    </div>
                	<div class="row">
                    	<div class="col-xs-12 col-sm-12">&nbsp;</div>
                    </div>
                    
                    <s:form action="viewTicket.action" method="post" id="seatForm">
                	<input type="hidden" name="filmId" value="${seats.filmId }" />
                	<input type="hidden" name="showTimeId" value="${seats.showTimeId }" />
                	
                	<div class="row">
                    	<div class="col-xs-12 col-sm-12 text-center">
                        	<ul class="bs-glyphicons">
                        	<s:iterator value="#request.seats.seatList" id="seat" status="s">
                        		<s:if test="isSold">
                        			<li value="${seat.seatId }" class="sold"><span class="icon-user3 font44"></span><p><s:property value="seatName" /><span style="display:none;"><s:checkbox name="buySeats" fieldValue="" value="false"/></span></p></li>
                        		</s:if>
                        		<s:else>
                        			<li value="${seat.seatId }"><span class="icon-user3 font44"></span><p><s:property value="seatName" /><span style="display:none;"><s:checkbox name="buySeats" fieldValue="" value="false"/></span></p></li>
                        		</s:else>                        		
                        	</s:iterator>
                            </ul>
                        </div>
                    </div>
                    <div class="row">
                    	<div class="col-xs-12 col-sm-12 text-center">
                            <div class="radio-inline">
                              <label>
                                <input type="radio" name="price" id="genePrice" value="${requestScope.seats.genePrice}" checked />普通票（<s:property value="#request.seats.genePrice"/>元）</label>
                            </div>                            
                            <div class="radio-inline">
                              <label>
                                <input type="radio" name="price" id="teamPrice" value="${requestScope.seats.teamPrice }"/>团体票（<s:property value="#request.seats.teamPrice"/>元 ×6）</label>
                            </div>                    
                            <div class="radio-inline">
                              <label>
                                <input type="radio" name="price" id="stuPrice" value="${requestScope.seats.stuPrice }"/>学生票（<s:property value="#request.seats.stuPrice"/>元）</label>
                            </div>
                            
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-xs-12 col-sm-12 text-center">
                            <s:submit cssClass="btn btn-primary" id="submitBtn" value="确认座位" />
                        </div>
                    </div>
                    </s:form>
                    <div class="row">
                    	<div class="col-xs-12 col-sm-12">&nbsp;</div>
                    </div>
                    <div class="row">
                    <div class="col-xs-12 col-sm-12 text-center">
                    	<div class="panel panel-default">
                          <div class="panel-heading">说明事项</div>
                          <div class="panel-body text-left">
                            <p>1.红色座位为已经售出座位，不能再选定；绿色为您要预定的座位。</p>                      
                            <p>2.点击白色座位即可选中，可同时选中多个座位；点击绿色座位可取消选择。</p>                                                  
                            <p>3.团体票需选足6张；该厅剩余座位不足6张时，需选定全部剩余座位。</p>
                          </div>
                        </div>
                    </div>
                    </div>
                </div>
		</div>	
		
		
      <hr>
      <footer>
        <p>&copy; Company 2013</p>
      </footer>
    </div> <!-- /container -->
  </body>
</html>
